home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / c / gcc261ud-c.lha / gnu / os-include / inline / strsup.h < prev    next >
C/C++ Source or Header  |  1994-10-24  |  1KB  |  85 lines

  1. #if !defined(_STRSUP_H) && defined(__OPTIMIZE__)
  2.  
  3. #define _STRSUP_H
  4.  
  5. #include <sys/types.h>
  6.  
  7. extern inline size_t strlen_plus_one(const char *string)
  8. {
  9.   const char *s=string;
  10.  
  11.   while(*s++)
  12.     ;
  13.   return (s-string);
  14. }
  15.  
  16. extern inline size_t strlen(const char *string)
  17. {
  18.   const char *s=string;
  19.  
  20.   while(*s++)
  21.     ;
  22.   return ~(string-s);
  23. }
  24.  
  25. extern inline char *strcpy(char *s1,const char *s2)
  26. { char *s=s1;
  27.   do
  28.     *s++=*s2;
  29.   while(*s2++!='\0');
  30.   return s1;
  31. }
  32.  
  33. extern inline char *strcat(char *s1,const char *s2)
  34.   char *s=s1;
  35.  
  36.   while(*s++)
  37.     ;
  38.   --s;
  39.   while((*s++=*s2++))
  40.     ;
  41.   return s1;
  42. }
  43.  
  44. extern inline char *strchr(const char *s,int c)
  45. {
  46.   while (*s!=(char)c)
  47.     if (!(*s++))
  48.     {
  49.       s=NULL;
  50.       break;
  51.     }
  52.   return (char *)s;
  53. }
  54.  
  55. extern inline char *strupr(char *s)
  56. {
  57.   unsigned char *s1;
  58.  
  59.   s1=(unsigned char *)s;
  60.   while(*s1)
  61.   {
  62.     if ((*s1>('a'-1)) && (*s1<('z'+1)))
  63.       *s1-='a'-'A';
  64.     s1++;
  65.   }
  66.   return s;
  67. }
  68.  
  69. extern inline char *strlwr(char *s)
  70. {
  71.   unsigned char *s1;
  72.  
  73.   s1=(unsigned char *)s;
  74.   while(*s1)
  75.   {
  76.     if ((*s1>('A'-1)) && (*s1<('Z'+1)))
  77.       *s1+='a'-'A';
  78.     s1++;
  79.   }
  80.   return s;
  81. }
  82.  
  83. #endif /* _STRSUP_H */
  84.